const { BondViewGroup, StaticViewGroup, View, ViewGroup } = require("./src/view");
const { DataSet, Service, TransactDataSet } = require("./src/dataset");
const Passable = require("./src/lib/passable");
const WorkerFactory = require('./src/lib/worker');
const { view, root, action, handler, subscribe, compute, binder, source, watch, frames, inspect } = require("./src/annotation");
const {
    clone,
    encodeHTML,
    excuteStyle,
    extend,
    hashCode,
    isArray,
    isEqual,
    isFunction,
    isObject,
    isPlainObject,
    isQueryString,
    isString,
    randomid,
    isBrowser,
    guid
} = require("./src/lib/helper");
const BrowserContext = require("./src/ctx/browser");
const env = require("./src/ctx/env");
const Manager = require("./src");
const { Stream, PullStream } = require('./src/ctx/stream');
const Queue = require('./src/lib/queue');
const { Store, CacheStore } = require('./src/lib/store');

if (isBrowser()) {
    const manager = new Manager(BrowserContext);
    manager._context.window.Ada = {
        boot(ops) {
            manager.boot(ops);
        },
        unpack(appName, info) {
            manager.unpack(appName, info);
        },
        installModule(name, module) {
            manager.installModule(name, module);
        },
        recover(info) {
            manager.recover(info);
        }
    };
}

module.exports = {
    View,
    ViewGroup,
    StaticViewGroup,
    BondViewGroup,
    Service,
    DataSet,
    TransactDataSet,
    Passable,
    WorkerFactory,
    Stream,
    PullStream,
    lib: {
        Queue,
        WorkerFactory,
        Store,
        CacheStore,
        Passable
    },
    util: {
        randomid,
        hashCode,
        isString,
        isFunction,
        isEqual,
        isObject,
        isPlainObject,
        isArray,
        isQueryString,
        excuteStyle,
        encodeHTML,
        extend,
        clone,
        guid
    },
    view,
    root,
    action,
    handler,
    subscribe,
    compute,
    binder,
    source,
    watch,
    frames,
    inspect,
    env
};